Hệ thống xếp lịch học tín chỉ cho sinh viên CNTT trên PHP & MySQL
111.157 lượt xem;
- notices_view.php
- project /
1 <?php
2 // This script and data application were generated by AppGini 5.72
3 // Download AppGini for free from https://bigprof.com/appgini/download/
4
5 $currDir=dirname(__FILE__);
6 include("$currDir/defaultLang.php");
7 include("$currDir/language.php");
8 include("$currDir/lib.php");
9 @include("$currDir/hooks/notices.php");
10 include("$currDir/notices_dml.php");
11
12 // mm: can the current member access this page?
13 $perm=getTablePermissions('notices');
14 if(!$perm[0]){
15 echo error_message($Translation['tableAccessDenied'], false);
16 echo '<script>setTimeout("window.location=\'index.php?signOut=1\'", 2000);</script>';
17 exit;
18 }
19
20 $x = new DataList;
21 $x->TableName = "notices";
22
23 // Fields that can be displayed in the table view
24 $x->QueryFieldsTV = array(
25 "`notices`.`id`" => "id",
26 "`notices`.`notice`" => "notice",
27 "IF( CHAR_LENGTH(`schools1`.`name`), CONCAT_WS('', `schools1`.`name`), '') /* School */" => "school",
28 "IF( CHAR_LENGTH(`departments1`.`name`), CONCAT_WS('', `departments1`.`name`), '') /* Department */" => "department",
29 "`notices`.`year_of_study`" => "year_of_study",
30 "if(`notices`.`date`,date_format(`notices`.`date`,'%m/%d/%Y'),'')" => "date"
31 );
32 // mapping incoming sort by requests to actual query fields
33 $x->SortFields = array(
34 1 => '`notices`.`id`',
35 2 => 2,
36 3 => '`schools1`.`name`',
37 4 => '`departments1`.`name`',
38 5 => 5,
39 6 => '`notices`.`date`'
40 );
41
42 // Fields that can be displayed in the csv file
43 $x->QueryFieldsCSV = array(
44 "`notices`.`id`" => "id",
45 "`notices`.`notice`" => "notice",
46 "IF( CHAR_LENGTH(`schools1`.`name`), CONCAT_WS('', `schools1`.`name`), '') /* School */" => "school",
47 "IF( CHAR_LENGTH(`departments1`.`name`), CONCAT_WS('', `departments1`.`name`), '') /* Department */" => "department",
48 "`notices`.`year_of_study`" => "year_of_study",
49 "if(`notices`.`date`,date_format(`notices`.`date`,'%m/%d/%Y'),'')" => "date"
50 );
51 // Fields that can be filtered
52 $x->QueryFieldsFilters = array(
53 "`notices`.`id`" => "ID",
54 "`notices`.`notice`" => "Notice",
55 "IF( CHAR_LENGTH(`schools1`.`name`), CONCAT_WS('', `schools1`.`name`), '') /* School */" => "School",
56 "IF( CHAR_LENGTH(`departments1`.`name`), CONCAT_WS('', `departments1`.`name`), '') /* Department */" => "Department",
57 "`notices`.`year_of_study`" => "Year of study",
58 "`notices`.`date`" => "Date"
59 );
60
61 // Fields that can be quick searched
62 $x->QueryFieldsQS = array(
63 "`notices`.`id`" => "id",
64 "`notices`.`notice`" => "notice",
65 "IF( CHAR_LENGTH(`schools1`.`name`), CONCAT_WS('', `schools1`.`name`), '') /* School */" => "school",
66 "IF( CHAR_LENGTH(`departments1`.`name`), CONCAT_WS('', `departments1`.`name`), '') /* Department */" => "department",
67 "`notices`.`year_of_study`" => "year_of_study",
68 "if(`notices`.`date`,date_format(`notices`.`date`,'%m/%d/%Y'),'')" => "date"
69 );
70
71 // Lookup fields that can be used as filterers
72 $x->filterers = array( 'school' => 'School', 'department' => 'Department');
73
74 $x->QueryFrom = "`notices` LEFT JOIN `schools` as schools1 ON `schools1`.`id`=`notices`.`school` LEFT JOIN `departments` as departments1 ON `departments1`.`id`=`notices`.`department` ";
75 $x->QueryWhere = '';
76 $x->QueryOrder = '';
77
78 $x->AllowSelection = 1;
79 $x->HideTableView = ($perm[2]==0 ? 1 : 0);
80 $x->AllowDelete = $perm[4];
81 $x->AllowMassDelete = true;
82 $x->AllowInsert = $perm[1];
83 $x->AllowUpdate = $perm[3];
84 $x->SeparateDV = 1;
85 $x->AllowDeleteOfParents = 0;
86 $x->AllowFilters = 1;
87 $x->AllowSavingFilters = 1;
88 $x->AllowSorting = 1;
89 $x->AllowNavigation = 1;
90 $x->AllowPrinting = 1;
91 $x->AllowCSV = 1;
92 $x->RecordsPerPage = 10;
93 $x->QuickSearch = 1;
94 $x->QuickSearchText = $Translation["quick search"];
95 $x->ScriptFileName = "notices_view.php";
96 $x->RedirectAfterInsert = "notices_view.php?SelectedID=#ID#";
97 $x->TableTitle = "Thông báo";
98 $x->TableIcon = "resources/table_icons/clipboard_empty.png";
99 $x->PrimaryKey = "`notices`.`id`";
100
101 $x->ColWidth = array( 150, 150, 150, 150, 150);
102 $x->ColCaption = array("Thông báo", "Lớp học", "Môn học", "Học kỳ", "Ngày");
103 $x->ColFieldName = array('notice', 'school', 'department', 'year_of_study', 'date');
104 $x->ColNumber = array(2, 3, 4, 5, 6);
105
106 // template paths below are based on the app main directory
107 $x->Template = 'templates/notices_templateTV.html';
108 $x->SelectedTemplate = 'templates/notices_templateTVS.html';
109 $x->TemplateDV = 'templates/notices_templateDV.html';
110 $x->TemplateDVP = 'templates/notices_templateDVP.html';
111
112 $x->ShowTableHeader = 1;
113 $x->TVClasses = "";
114 $x->DVClasses = "";
115 $x->HighlightColor = '#FFF0C2';
116
117 // mm: build the query based on current member's permissions
118 $DisplayRecords = $_REQUEST['DisplayRecords'];
119 if(!in_array($DisplayRecords, array('user', 'group'))){ $DisplayRecords = 'all'; }
120 if($perm[2]==1 || ($perm[2]>1 && $DisplayRecords=='user' && !$_REQUEST['NoFilter_x'])){ // view owner only
121 $x->QueryFrom.=', membership_userrecords';
122 $x->QueryWhere="where `notices`.`id`=membership_userrecords.pkValue and membership_userrecords.tableName='notices' and lcase(membership_userrecords.memberID)='".getLoggedMemberID()."'";
123 }elseif($perm[2]==2 || ($perm[2]>2 && $DisplayRecords=='group' && !$_REQUEST['NoFilter_x'])){ // view group only
124 $x->QueryFrom.=', membership_userrecords';
125 $x->QueryWhere="where `notices`.`id`=membership_userrecords.pkValue and membership_userrecords.tableName='notices' and membership_userrecords.groupID='".getLoggedGroupID()."'";
126 }elseif($perm[2]==3){ // view all
127 // no further action
128 }elseif($perm[2]==0){ // view none
129 $x->QueryFields = array("Not enough permissions" => "NEP");
130 $x->QueryFrom = '`notices`';
131 $x->QueryWhere = '';
132 $x->DefaultSortField = '';
133 }
134 // hook: notices_init
135 $render=TRUE;
136 if(function_exists('notices_init')){
137 $args=array();
138 $render=notices_init($x, getMemberInfo(), $args);
139 }
140
141 if($render) $x->Render();
142
143 // hook: notices_header
144 $headerCode='';
145 if(function_exists('notices_header')){
146 $args=array();
147 $headerCode=notices_header($x->ContentType, getMemberInfo(), $args);
148 }
149 if(!$headerCode){
150 include_once("$currDir/header.php");
151 }else{
152 ob_start(); include_once("$currDir/header.php"); $dHeader=ob_get_contents(); ob_end_clean();
153 echo str_replace('<%%HEADER%%>', $dHeader, $headerCode);
154 }
155
156 echo $x->HTML;
157 // hook: notices_footer
158 $footerCode='';
159 if(function_exists('notices_footer')){
160 $args=array();
161 $footerCode=notices_footer($x->ContentType, getMemberInfo(), $args);
162 }
163 if(!$footerCode){
164 include_once("$currDir/footer.php");
165 }else{
166 ob_start(); include_once("$currDir/footer.php"); $dFooter=ob_get_contents(); ob_end_clean();
167 echo str_replace('<%%FOOTER%%>', $dFooter, $footerCode);
168 }
169 ?>
2 // This script and data application were generated by AppGini 5.72
3 // Download AppGini for free from https://bigprof.com/appgini/download/
4
5 $currDir=dirname(__FILE__);
6 include("$currDir/defaultLang.php");
7 include("$currDir/language.php");
8 include("$currDir/lib.php");
9 @include("$currDir/hooks/notices.php");
10 include("$currDir/notices_dml.php");
11
12 // mm: can the current member access this page?
13 $perm=getTablePermissions('notices');
14 if(!$perm[0]){
15 echo error_message($Translation['tableAccessDenied'], false);
16 echo '<script>setTimeout("window.location=\'index.php?signOut=1\'", 2000);</script>';
17 exit;
18 }
19
20 $x = new DataList;
21 $x->TableName = "notices";
22
23 // Fields that can be displayed in the table view
24 $x->QueryFieldsTV = array(
25 "`notices`.`id`" => "id",
26 "`notices`.`notice`" => "notice",
27 "IF( CHAR_LENGTH(`schools1`.`name`), CONCAT_WS('', `schools1`.`name`), '') /* School */" => "school",
28 "IF( CHAR_LENGTH(`departments1`.`name`), CONCAT_WS('', `departments1`.`name`), '') /* Department */" => "department",
29 "`notices`.`year_of_study`" => "year_of_study",
30 "if(`notices`.`date`,date_format(`notices`.`date`,'%m/%d/%Y'),'')" => "date"
31 );
32 // mapping incoming sort by requests to actual query fields
33 $x->SortFields = array(
34 1 => '`notices`.`id`',
35 2 => 2,
36 3 => '`schools1`.`name`',
37 4 => '`departments1`.`name`',
38 5 => 5,
39 6 => '`notices`.`date`'
40 );
41
42 // Fields that can be displayed in the csv file
43 $x->QueryFieldsCSV = array(
44 "`notices`.`id`" => "id",
45 "`notices`.`notice`" => "notice",
46 "IF( CHAR_LENGTH(`schools1`.`name`), CONCAT_WS('', `schools1`.`name`), '') /* School */" => "school",
47 "IF( CHAR_LENGTH(`departments1`.`name`), CONCAT_WS('', `departments1`.`name`), '') /* Department */" => "department",
48 "`notices`.`year_of_study`" => "year_of_study",
49 "if(`notices`.`date`,date_format(`notices`.`date`,'%m/%d/%Y'),'')" => "date"
50 );
51 // Fields that can be filtered
52 $x->QueryFieldsFilters = array(
53 "`notices`.`id`" => "ID",
54 "`notices`.`notice`" => "Notice",
55 "IF( CHAR_LENGTH(`schools1`.`name`), CONCAT_WS('', `schools1`.`name`), '') /* School */" => "School",
56 "IF( CHAR_LENGTH(`departments1`.`name`), CONCAT_WS('', `departments1`.`name`), '') /* Department */" => "Department",
57 "`notices`.`year_of_study`" => "Year of study",
58 "`notices`.`date`" => "Date"
59 );
60
61 // Fields that can be quick searched
62 $x->QueryFieldsQS = array(
63 "`notices`.`id`" => "id",
64 "`notices`.`notice`" => "notice",
65 "IF( CHAR_LENGTH(`schools1`.`name`), CONCAT_WS('', `schools1`.`name`), '') /* School */" => "school",
66 "IF( CHAR_LENGTH(`departments1`.`name`), CONCAT_WS('', `departments1`.`name`), '') /* Department */" => "department",
67 "`notices`.`year_of_study`" => "year_of_study",
68 "if(`notices`.`date`,date_format(`notices`.`date`,'%m/%d/%Y'),'')" => "date"
69 );
70
71 // Lookup fields that can be used as filterers
72 $x->filterers = array( 'school' => 'School', 'department' => 'Department');
73
74 $x->QueryFrom = "`notices` LEFT JOIN `schools` as schools1 ON `schools1`.`id`=`notices`.`school` LEFT JOIN `departments` as departments1 ON `departments1`.`id`=`notices`.`department` ";
75 $x->QueryWhere = '';
76 $x->QueryOrder = '';
77
78 $x->AllowSelection = 1;
79 $x->HideTableView = ($perm[2]==0 ? 1 : 0);
80 $x->AllowDelete = $perm[4];
81 $x->AllowMassDelete = true;
82 $x->AllowInsert = $perm[1];
83 $x->AllowUpdate = $perm[3];
84 $x->SeparateDV = 1;
85 $x->AllowDeleteOfParents = 0;
86 $x->AllowFilters = 1;
87 $x->AllowSavingFilters = 1;
88 $x->AllowSorting = 1;
89 $x->AllowNavigation = 1;
90 $x->AllowPrinting = 1;
91 $x->AllowCSV = 1;
92 $x->RecordsPerPage = 10;
93 $x->QuickSearch = 1;
94 $x->QuickSearchText = $Translation["quick search"];
95 $x->ScriptFileName = "notices_view.php";
96 $x->RedirectAfterInsert = "notices_view.php?SelectedID=#ID#";
97 $x->TableTitle = "Thông báo";
98 $x->TableIcon = "resources/table_icons/clipboard_empty.png";
99 $x->PrimaryKey = "`notices`.`id`";
100
101 $x->ColWidth = array( 150, 150, 150, 150, 150);
102 $x->ColCaption = array("Thông báo", "Lớp học", "Môn học", "Học kỳ", "Ngày");
103 $x->ColFieldName = array('notice', 'school', 'department', 'year_of_study', 'date');
104 $x->ColNumber = array(2, 3, 4, 5, 6);
105
106 // template paths below are based on the app main directory
107 $x->Template = 'templates/notices_templateTV.html';
108 $x->SelectedTemplate = 'templates/notices_templateTVS.html';
109 $x->TemplateDV = 'templates/notices_templateDV.html';
110 $x->TemplateDVP = 'templates/notices_templateDVP.html';
111
112 $x->ShowTableHeader = 1;
113 $x->TVClasses = "";
114 $x->DVClasses = "";
115 $x->HighlightColor = '#FFF0C2';
116
117 // mm: build the query based on current member's permissions
118 $DisplayRecords = $_REQUEST['DisplayRecords'];
119 if(!in_array($DisplayRecords, array('user', 'group'))){ $DisplayRecords = 'all'; }
120 if($perm[2]==1 || ($perm[2]>1 && $DisplayRecords=='user' && !$_REQUEST['NoFilter_x'])){ // view owner only
121 $x->QueryFrom.=', membership_userrecords';
122 $x->QueryWhere="where `notices`.`id`=membership_userrecords.pkValue and membership_userrecords.tableName='notices' and lcase(membership_userrecords.memberID)='".getLoggedMemberID()."'";
123 }elseif($perm[2]==2 || ($perm[2]>2 && $DisplayRecords=='group' && !$_REQUEST['NoFilter_x'])){ // view group only
124 $x->QueryFrom.=', membership_userrecords';
125 $x->QueryWhere="where `notices`.`id`=membership_userrecords.pkValue and membership_userrecords.tableName='notices' and membership_userrecords.groupID='".getLoggedGroupID()."'";
126 }elseif($perm[2]==3){ // view all
127 // no further action
128 }elseif($perm[2]==0){ // view none
129 $x->QueryFields = array("Not enough permissions" => "NEP");
130 $x->QueryFrom = '`notices`';
131 $x->QueryWhere = '';
132 $x->DefaultSortField = '';
133 }
134 // hook: notices_init
135 $render=TRUE;
136 if(function_exists('notices_init')){
137 $args=array();
138 $render=notices_init($x, getMemberInfo(), $args);
139 }
140
141 if($render) $x->Render();
142
143 // hook: notices_header
144 $headerCode='';
145 if(function_exists('notices_header')){
146 $args=array();
147 $headerCode=notices_header($x->ContentType, getMemberInfo(), $args);
148 }
149 if(!$headerCode){
150 include_once("$currDir/header.php");
151 }else{
152 ob_start(); include_once("$currDir/header.php"); $dHeader=ob_get_contents(); ob_end_clean();
153 echo str_replace('<%%HEADER%%>', $dHeader, $headerCode);
154 }
155
156 echo $x->HTML;
157 // hook: notices_footer
158 $footerCode='';
159 if(function_exists('notices_footer')){
160 $args=array();
161 $footerCode=notices_footer($x->ContentType, getMemberInfo(), $args);
162 }
163 if(!$footerCode){
164 include_once("$currDir/footer.php");
165 }else{
166 ob_start(); include_once("$currDir/footer.php"); $dFooter=ob_get_contents(); ob_end_clean();
167 echo str_replace('<%%FOOTER%%>', $dFooter, $footerCode);
168 }
169 ?>